package com.wthink.hzgj.data.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.wthink.hzgj.data.domain.Line

@Dao
interface LineDao {

    @Query("SELECT * FROM Line where name !='' ")
    suspend fun list(): List<Line>

    @Query("SELECT * FROM Line where line=:lineId")
    suspend fun findById(lineId: String): Line?

    @Query("SELECT * FROM Line where name=:lineName")
    suspend fun findByName(lineName: String): Line?

    @Query("DELETE FROM Line")
    suspend fun delete()

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun save(data: List<Line>)

    @Query("UPDATE Line set name=:lineName where line=:lineId")
    suspend fun updateNameById(lineId: String, lineName: String)

}